home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00091_Blender Jug Behavior.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  6.2 KB  |  292 lines

  1. property pSpr, pLidUpMember, pJugMember, pGlassMask, pGlassIce, pBlended, pLidUpNoIceMember, pLidUpWithIceMember, pNoShadow, pIceAmount, pMaxIceIncrements, pLidUp, pLidTimer, pLastDest, pGlassType, pFullBlender, pEmptyBlender, pPouring, pContents, pContentString, pTilt, pCapacity, pIcePerScoop, pOverItem, pTimer, pHotRect
  2. global gFloatSprite
  3.  
  4. on beginSprite me
  5.   pGlassType = #blender
  6.   pSpr = sprite(me.spriteNum)
  7.   pGlassMask = sprite(me.spriteNum + 1)
  8.   pGlassIce = pSpr
  9.   pJugMember = pSpr.member
  10.   pMaskMember = pJugMember
  11.   pEmptyBlender = pJugMember
  12.   pLidUpNoIceMember = nextMember(pJugMember, -1)
  13.   pLidUpWithIceMember = nextMember(pJugMember, -4)
  14.   pNoShadow = nextMember(pJugMember, -2)
  15.   pFullBlender = nextMember(pJugMember, -3)
  16.   pCapacity = 16.0
  17.   pMaxIceIncrements = 1
  18.   pIcePerScoop = pCapacity / (2.0 * pMaxIceIncrements)
  19.   mEmptyGlass(me)
  20.   pLidUp = 0
  21.   pOverItem = 0
  22.   mReplaceIt(me, 1)
  23.   pHotRect = rect(248, 315, 284, 365)
  24. end
  25.  
  26. on mEmptyGlass me
  27.   global gLastVessel
  28.   if gLastVessel = pGlassType then
  29.     setPourClockText(" The Blender is Empty")
  30.   end if
  31.   pIceAmount = 0
  32.   pBlended = 0
  33.   pContents = [:]
  34.   pContentString = EMPTY
  35.   pLastDest = VOID
  36.   pLidUpMember = pLidUpNoIceMember
  37.   pJugMember = pEmptyBlender
  38.   pSpr.member = pJugMember
  39.   sendSprite(me.spriteNum + 1, #mEmptyGlass)
  40. end
  41.  
  42. on mEmptyIfLastVessel me, barGlassSprite
  43.   if pLastDest = barGlassSprite then
  44.     mEmptyGlass(me)
  45.   end if
  46. end
  47.  
  48. on mReplaceTop me
  49.   if pLidUp or (pSpr.member <> pJugMember) then
  50.     pLidUp = 0
  51.     pLidTimer = VOID
  52.     soundFX2("top_on_pitcher", 0, 0)
  53.     pSpr.member = pJugMember
  54.   end if
  55. end
  56.  
  57. on mPopTop me, Force
  58.   if not pLidUp then
  59.     if not Force then
  60.       if voidp(pLidTimer) then
  61.         pLidTimer = nowTicks()
  62.         exit
  63.       else
  64.         if ticksSince(pLidTimer) < 15 then
  65.           exit
  66.         end if
  67.       end if
  68.     end if
  69.     soundFX2("top_off_pitcher", 0, 0)
  70.     pSpr.member = pLidUpMember
  71.     pLidUp = 1
  72.     mupdateDisplay(me)
  73.   end if
  74. end
  75.  
  76. on mBlended me
  77.   if not voidp(pContents[#ice]) then
  78.     pContents[#blend] = 1
  79.     if voidp(getaProp(pContents, #Slush)) then
  80.       pContents[#Slush] = 0
  81.     end if
  82.     pContents[#Slush] = pContents[#Slush] + (pContents[#ice] / 2.0)
  83.     pContents[#ice] = 0
  84.     deleteProp(pContents, #ice)
  85.     pIceAmount = 0
  86.     mRefreshIce(me)
  87.     sendSprite(pGlassMask, #mUpdateLiquidLevel, pSpr)
  88.     mupdateDisplay(me)
  89.     pBlended = 1
  90.   end if
  91. end
  92.  
  93. on mupdateDisplay me
  94.   global gLastVessel
  95.   gLastVessel = pGlassType
  96.   pContentString = buildVesselContentList(pSpr, pGlassType, " The Blender is Empty")
  97.   showDrinkContents(pGlassType, pContentString, VOID)
  98. end
  99.  
  100. on mStirred me
  101.   if countStirrableIngredients(pContents) > 1 then
  102.     pContents[#stir] = 1
  103.   end if
  104. end
  105.  
  106. on mInHotRect me
  107.   return inside(the mouseLoc, pHotRect)
  108. end
  109.  
  110. on mouseEnter me
  111.   pTimer = nowTicks()
  112.   pLidTimer = VOID
  113.   pOverItem = 1
  114.   if draggingBarTopGlass() then
  115.     exit
  116.   end if
  117.   showToolTip(pSpr, pGlassType)
  118. end
  119.  
  120. on mouseWithin me
  121.   if mInHotRect(me) then
  122.     if draggingBottleOrSpoon() and not pPouring then
  123.       mPopTop(me)
  124.     else
  125.       if draggingIngredient() then
  126.         pTimer = nowTicks()
  127.       else
  128.         if tipTickRange(pTimer) then
  129.           forceToolTip(pSpr, pGlassType)
  130.           mupdateDisplay(me)
  131.         else
  132.           dismissToolTip()
  133.         end if
  134.       end if
  135.     end if
  136.   else
  137.     mouseLeave(me)
  138.   end if
  139. end
  140.  
  141. on mouseLeave me
  142.   if not pPouring and draggingBottleOrSpoon() then
  143.     mReplaceTop(me)
  144.   end if
  145.   pOverItem = 0
  146.   if not draggingSpoon() then
  147.     hideToolTip()
  148.     hideDrinkContents()
  149.   end if
  150. end
  151.  
  152. on mSetNewTilt me, newTilt
  153.   pTilt = newTilt
  154.   if pTilt = #right then
  155.     pDragMember = nextMember(pEmptyBlender, 1)
  156.   else
  157.     pDragMember = nextMember(pEmptyBlender, 11)
  158.   end if
  159.   return pDragMember
  160. end
  161.  
  162. on mouseDown me
  163.   if the doubleClick then
  164.     exit
  165.   end if
  166.   if draggingAnything() and not pPouring then
  167.     mPopTop(me, 1)
  168.     if draggingBottleThang() then
  169.       pourIt(mGetReceiveSound(me))
  170.     end if
  171.   else
  172.     if pPouring then
  173.       replaceDraggingAnything()
  174.     else
  175.       replaceDraggingAnything()
  176.       sendSprite(gFloatSprite, #mPickUpBottle, pSpr, VOID, VOID, pGlassType, mGetPourSound(me), "pitcher_off_blender", the mouseLoc - point(20, 15))
  177.       pSpr.member = pNoShadow
  178.       pPouring = 1
  179.       pGlassMask.visible = 0
  180.     end if
  181.   end if
  182. end
  183.  
  184. on mOverItem me, bottleSprite, spoutLoc
  185.   if pPouring then
  186.     return 0
  187.   else
  188.     return inside(spoutLoc, pHotRect)
  189.   end if
  190. end
  191.  
  192. on mReplaceIt me, noSound
  193.   pSpr.visible = 1
  194.   pSpr.member = pJugMember
  195.   pPouring = 0
  196.   pTilt = #left
  197.   pGlassMask.visible = 1
  198.   if not noSound then
  199.     soundFX2("pitcher_on_blender", 0, 0)
  200.   end if
  201. end
  202.  
  203. on mGetReceiveSound me
  204.   if mHasIce(me) then
  205.     soundName = "water_into_blender_wice"
  206.   else
  207.     soundName = "water_into_blender"
  208.   end if
  209.   return soundName
  210. end
  211.  
  212. on mGetPourSound me
  213.   if mIsEmpty(me) then
  214.     soundName = VOID
  215.   else
  216.     if pBlended then
  217.       soundName = "blender_slush_into_glass"
  218.     else
  219.       soundName = VOID
  220.     end if
  221.   end if
  222.   return soundName
  223. end
  224.  
  225. on mIsHoldingVolume me
  226.   return calcContents(pContents)
  227. end
  228.  
  229. on mIsHoldingLiquor me
  230.   return calcLiquorContents(pContents)
  231. end
  232.  
  233. on mIsHoldingLiquid me
  234.   return calcLiquidContents(pContents)
  235. end
  236.  
  237. on mIsHoldingPourable me
  238.   return calcPourableContents(pContents)
  239. end
  240.  
  241. on mIsEmpty me
  242.   return calcEmpty(pContents)
  243. end
  244.  
  245. on mHasIce me
  246.   if voidp(pContents[#ice]) then
  247.     return 0
  248.   else
  249.     return integer(pContents[#ice])
  250.   end if
  251. end
  252.  
  253. on mGetBlendSound me
  254.   if mIsEmpty(me) then
  255.     soundName = "blend_empty"
  256.   else
  257.     if mHasIce(me) then
  258.       soundName = "blend_icewater"
  259.     else
  260.       soundName = "blend_water"
  261.     end if
  262.   end if
  263.   return soundName
  264. end
  265.  
  266. on mFill me, ingredient, liquidColor
  267.   return fillVessel(me, ingredient, liquidColor)
  268. end
  269.  
  270. on mFillIce me, masterSprite
  271.   if (pIceAmount + 1) <= pMaxIceIncrements then
  272.     pJugMember = pFullBlender
  273.     pLidUpMember = pLidUpWithIceMember
  274.     pSpr.member = pLidUpMember
  275.   else
  276.     alertBeep()
  277.     return 0
  278.   end if
  279.   addIce(pSpr, masterSprite, pMaxIceIncrements, VOID, "ice_into_blender")
  280. end
  281.  
  282. on mRefreshIce me
  283.   if pIceAmount = pMaxIceIncrements then
  284.     pJugMember = pFullBlender
  285.     pLidUpMember = pLidUpWithIceMember
  286.   else
  287.     pJugMember = pEmptyBlender
  288.     pLidUpMember = pLidUpNoIceMember
  289.   end if
  290.   pSpr.member = pJugMember
  291. end
  292.